package com.ecity.util {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.utils.ByteArray;
	/**
	 * ...
	 * @author yicheng.zhang
	 */
	public class UIFactory {
		private static const JPG:String = "image/jpeg";
		private static const PNG:String = "image/png";
		private static const GIF:String = "image/gif";
		private static const SWF:String = "application/x-shockwave-flash";
		
		private static var _uimap:HashMap = new HashMap();
		private static var _swfmap:HashMap= new HashMap();
		private static var _configmap:HashMap= new HashMap();

		public static function getConfiger():XML {
			return _configmap.get("Configer") as XML;
		}
		
		public static function getBitmap(name:String):Bitmap {
			var bmd:Bitmap = uimap.get(name) as Bitmap;
			return bmd;
		}
		
		public static function getMovieClip(name:String):MovieClip {
			var mc:MovieClip = _swfmap.get(name) as MovieClip;
			return mc;
		}
		
		public static function getBitmapData(name:String, isClone:Boolean = false):BitmapData {
			if (isClone) {
				return getBitmap(name).bitmapData.clone();
			}else {
				return getBitmap(name).bitmapData;
			}
		}
		
		public static function get uimap():HashMap {
			if (_uimap.size() > 0) {
				return _uimap;
			}else {
				return new HashMap();
			}
		}

	
		
		public static function putConfiger(name:String, value:Object):void {
			_configmap.put(name, value);
		}
		public static function put(name:String, value:Object, type:String):void {
			trace(type);
			switch(type) {
				case SWF:
					_swfmap.put(name, value);
					break;
				default:
					_uimap.put(name, value);
			}
		}
		
	}
}


